package com.foredu.fiqs.web.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.foredu.fiqs.domain.Clazz;
import com.foredu.fiqs.domain.Department;
import com.foredu.fiqs.domain.Role;
import com.foredu.fiqs.domain.Teacher;
import com.foredu.fiqs.domain.User;
import com.foredu.fiqs.service.IManagementService;

public class ClazzAction extends AbstractBaseDispatchAction {

	private IManagementService managementService = null;

	public IManagementService getManagementService() {
		return managementService;
	}

	public void setManagementService(IManagementService managementService) {
		this.managementService = managementService;
	}

	// 跳转到班级管理列表页面
	public ActionForward list(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		// 获得当前登录用户
		User user = managementService.findUserByUsername(this.getPrincipal().getUsername());
		Role role = managementService.findRoleByName("DEPT_ADMIN");
		
		return mapping.findForward("list");
	}

	// 跳转到班级添加页面
	public ActionForward add(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		User user = managementService.findUserByUsername(this.getPrincipal().getUsername());
		Role role = managementService.findRoleByName("DEPT_ADMIN");

		return mapping.findForward("add");
	}

	// 完成添加操作
	public ActionForward save(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("addSave");
	}

	// 跳转到班级修改页面
	public ActionForward update(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		User user = managementService.findUserByUsername(this.getPrincipal().getUsername());
		Role role = managementService.findRoleByName("DEPT_ADMIN");

		return mapping.findForward("update");
	}

	// 完成班级修改
	public ActionForward updateSave(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("updateSave");
	}

	// 完成班级删除操作
	public ActionForward delete(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		return mapping.findForward("delete");
	}

}
